package TUI;
import Model.*;
import Controller.*;
import java.util.*;

public class MainMenu
{
    private String input;
    private InputReader reader = new InputReader();
    public MainMenu()
    {
        printWelcome();
        String input=reader.getInput().trim().toLowerCase();
        if(input.startsWith("exit"))
        {
            printGoodbye();
            System.exit(0);
        }
    
        switch (input)
        {case "1": 
            System.out.print('\u000C');
            
            customers();
            input=reader.getInput().trim().toLowerCase();
         case "2":
            System.out.print('\u000C');
            employees();
            input=reader.getInput().trim().toLowerCase();
            
         case "3":
            System.out.print('\u000C');
            orders();
            input=reader.getInput().trim().toLowerCase();
            
         case "4":
            System.out.print('\u000C');
            products();
            input=reader.getInput().trim().toLowerCase();
            
         case "5":
            System.out.print('\u000C');
            machines();
            input=reader.getInput().trim().toLowerCase();
            
         case "6":
            System.out.print('\u000C');
            leases();
            input=reader.getInput().trim().toLowerCase();
            
         default:
            System.out.println("Unknown command, try again!");
            input=reader.getInput().trim().toLowerCase();
            
         
            
        }
    
    
    
    }

    public void printWelcome()
    {
        System.out.print('\u000C');
        System.out.println("______________________________");
        System.out.println("          Main menu           ");
        System.out.println("1.Customers");
        System.out.println("2.Employees");
        System.out.println("3.Orders");
        System.out.println("4.Products");
        System.out.println("5.Machines");
        System.out.println("6.Leases");
        System.out.println("Type exit to close the program");
        System.out.println("______________________________");
    }
    
    public void printGoodbye()
    {
        System.out.println("The program will now close");
    }
    
    public void customers()
    {
        System.out.println("1.Add customer");
        System.out.println("2.Search customer");
        System.out.println("3.Delete customer");
        System.out.println("4.Return to main menu");
        input=reader.getInput().trim().toLowerCase();
        if(input.startsWith("exit"))
        {
            printGoodbye();
            System.exit(0);
        }
        
        
        
        switch(input)
        {case "1":
            addCustomer();
            System.exit(0);
            break;
            
         case "2":
            String ID = reader.getInput("Insert ID to search");
            CustomerCtr.SearchCustomer(ID);
            break;
            
         case "3":
            String theID = reader.getInput("Insert ID to delete");
            CustomerCtr.DeleteCustomer(theID);
            break;
            
         case "4":
            printWelcome();
         
            
            
            
        }
    }

    public void employees()
    {
        System.out.println("1.Add employee");
        System.out.println("2.Search customer");
        System.out.println("3.Delete customer");
        System.out.println("4.Return to main menu");
    }

    public void orders()
    {
        System.out.println("1.Add order");
        System.out.println("2.Search order");
        System.out.println("3.Delete order");
        System.out.println("4.Return to main menu");
    }
    
    public void products()
    {
        System.out.println("1.Add product");
        System.out.println("2.Search product");
        System.out.println("3.Delete product");
        System.out.println("4.Return to main menu");
    }
    
    public void machines()
    {
        System.out.println("1.Add machine");
        System.out.println("2.Search machine");
        System.out.println("3.Delete machine");
        System.out.println("4.Return to main menu");
    }
    
    public void leases()
    {
        System.out.println("1.Add lease");
        System.out.println("2.Search lease");
        System.out.println("3.Delete lease");
        System.out.println("4.Return to main menu");
    }
    
    private void addCustomer()
    {
        String name = reader.getInput("Name");
        String ID = reader.getInput("ID");
        String adress = reader.getInput("Adress");
        String phone = reader.getInput("Phone");
        String email = reader.getInput("Email");
        String cprNo = reader.getInput("CprNo");
        CustomerCtr ctr= new CustomerCtr();
        Customer c = new Customer(name, ID, adress, phone,email,cprNo );
        
    }
}


